#pragma once

#include <time.h>
#include <stdint.h>

#ifdef __plusplus
extern "C" {
#endif

typedef uint64_t u64;

static inline
u64 us(void)
{
    struct timespec ts;
    clock_gettime(CLOCK_REALTIME, &ts);
    return (u64) ts.tv_sec * 1000000 + ts.tv_nsec / 1000;
}

static inline
u64 ms(void)
{
    return us() / 1000;
}
#ifdef __plusplus
}
#endif
